package com.yifeng.repo.base.constant;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by daibing on 2023/3/15.
 */
@Getter
@AllArgsConstructor
public enum DeployModeEnum {
    STANDALONE(1, "单机"),
    CLUSTER(2, "集群"),
    ;

    @EnumValue
    @JsonValue
    private final Integer code;

    private final String name;

    private static final Map<Integer, DeployModeEnum> mappings = new HashMap<>(4);

    static {
        for (DeployModeEnum msgChannel : values()) {
            mappings.put(msgChannel.getCode(), msgChannel);
        }
    }

    public static DeployModeEnum resolve(Integer code) {
        return (code != null ? mappings.get(code) : null);
    }
}
